home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / gnu / emacs_src_18_58.lha / emacs-18.58 / lisp / lpr.el < prev    next >
Lisp/Scheme  |  1992-02-21  |  3KB  |  72 lines

  1. ;; Print Emacs buffer on line printer.
  2. ;; Copyright (C) 1985, 1988 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 1, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  18. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.  
  21. ;(defconst lpr-switches nil
  22. ;  "*List of strings to pass as extra switch args to lpr when it is invoked.")
  23.  
  24. (defvar lpr-command (if (eq system-type 'usg-unix-v)
  25.             "lp" "lpr")
  26.   "Shell command for printing a file")
  27.  
  28. (defun lpr-buffer ()
  29.   "Print buffer contents as with Unix command `lpr'.
  30. `lpr-switches' is a list of extra switches (strings) to pass to lpr."
  31.   (interactive)
  32.   (print-region-1 (point-min) (point-max) lpr-switches))
  33.  
  34. (defun print-buffer ()
  35.   "Print buffer contents as with Unix command `lpr -p'.
  36. `lpr-switches' is a list of extra switches (strings) to pass to lpr."
  37.   (interactive)
  38.   (print-region-1 (point-min) (point-max) (cons "-p" lpr-switches)))
  39.  
  40. (defun lpr-region (start end)
  41.   "Print region contents as with Unix command `lpr'.
  42. `lpr-switches' is a list of extra switches (strings) to pass to lpr."
  43.   (interactive "r")
  44.   (print-region-1 start end lpr-switches))
  45.  
  46. (defun print-region (start end)
  47.   "Print region contents as with Unix command `lpr -p'.
  48. `lpr-switches' is a list of extra switches (strings) to pass to lpr."
  49.   (interactive "r")
  50.   (print-region-1 start end (cons "-p" lpr-switches)))
  51.  
  52. (defun print-region-1 (start end switches)
  53.   (let ((name (concat (buffer-name) " Emacs buffer"))
  54.     (width tab-width))
  55.     (save-excursion
  56.      (message "Spooling...")
  57.      (if (/= tab-width 8)
  58.      (let ((oldbuf (current-buffer)))
  59.       (set-buffer (get-buffer-create " *spool temp*"))
  60.       (widen) (erase-buffer)
  61.       (insert-buffer-substring oldbuf start end)
  62.       (setq tab-width width)
  63.       (untabify (point-min) (point-max))
  64.       (setq start (point-min) end (point-max))))
  65.      (apply 'call-process-region
  66.         (nconc (list start end lpr-command
  67.              nil nil nil)
  68.            (nconc (and (eq system-type 'berkeley-unix)
  69.                    (list "-J" name "-T" name))
  70.               switches)))
  71.      (message "Spooling...done"))))
  72.